<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script src="./vue.js"></script>
</head>
<body>
    <div id="emit-example-argument">
<magic-eight-ball v-on:give-advice="showAdvice"></magic-eight-ball>
    </div>
</body>
<script>
    Vue.component('magic-eight-ball',{
        data: function(){
            return{
                possibleAdvice:['Yes','No','Maybe']
            } 
        },
        methods:{
            giveAdvice:function(){
                var randomAdviceIndex=Math.floor(Math.random()*this.possibleAdvice.length)
                this.$emit('give-advice',this.possibleAdvice[randomAdviceIndex])
            }
        },
        template:`
        <button v-on:click="giveAdvice">Click me for advice
            </button>`
    })
    new Vue({
  el: '#emit-example-argument',
  methods: {
    showAdvice: function (advice) {
      alert(advice)
    }
  }
})
</script>
</html>